import re
from my_package import my_tools


result = re.match('hello', 'hello world')
print(result)

# \d 匹配阿拉伯数字   \D 相反
result = re.match(r'\d+', '331234')
print(result)

# \w 匹配字母数字下划线   \W 相反
result = re.match(r'\w+', 'ad89_*')
print(result)

# \s 匹配空白字符   \S 相反
result = re.match(r'\s+', '     ')
print(result)

# ^限制开头，$限制结尾
result = re.match(r'^\d+$', '234tr')
print(result)

# . 匹配任意字符
result = re.match(r'^code\d+-[\u4e00-\u9fa5]+-.+$', 'code04-模块-正则.py')
print(result)

# [] 区间
result = re.match(r'[abcd]+$', 'acde')
print(result)

# + 匹配1个或多个表达式

# * 匹配0个或多个表达式

# {} 匹配多少次
result = re.match(r'^abc{2,4}$','abcccc')
print(result)

# | 或者
result = re.match(r'^a+|b|c$', 'aa')
print(result)


# 身份证号校验
# result = re.match('^[1-9]\d{5}(19|20)\d{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)\d{3}[X\d]$','31010020001009543X')
result = my_tools.is_id_card('31010020001009543X')
print(result)
